package com.one.blocks.rbac.convert;

import com.one.blocks.mvc.convert.BaseDomainConvert;
import com.one.blocks.mvc.convert.BaseDomainExcelConvert;
import com.one.blocks.mvc.domain.BaseDomain;
import com.one.blocks.mvc.domain.Id;
import com.one.blocks.rbac.controller.excel.SysDictDataExcel;
import com.one.blocks.rbac.controller.query.SysDictDataQuery;
import com.one.blocks.rbac.controller.vo.SysDictDataVo;
import com.one.blocks.rbac.domain.SysDictData;
import com.one.blocks.rbac.util.SubjectHelper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

/**
 * @author <a href="mailto:idler41@163.con">idler41</a> created on 2023-12-06 16:10:52
 */
@Mapper(uses = {TimestampConvert.class}, imports = {SubjectHelper.class})
public interface SysDictDataConvert extends BaseDomainConvert<SysDictData, SysDictDataVo, SysDictDataQuery>, BaseDomainExcelConvert<SysDictData, SysDictDataExcel> {

    public static SysDictDataConvert INSTANCE = Mappers.getMapper(SysDictDataConvert.class);

    @Named("voToEntityIgnoreId")
    @Mapping(target = "state", defaultValue = "1")
    @Mapping(target = "defaultFlag", defaultValue = "0")
    @Mapping(target = Id.FIELD_NAME_ID, ignore = true)
    @Mapping(target = BaseDomain.FIELD_NAME_CREATE_ID, expression = "java(SubjectHelper.getSubjectId())")
    @Mapping(target = BaseDomain.FIELD_NAME_CREATE_TIME, expression = "java(SubjectHelper.getAccessTime())")
    @Mapping(target = BaseDomain.FIELD_NAME_UPDATE_ID, ignore = true)
    @Mapping(target = BaseDomain.FIELD_NAME_UPDATE_TIME, ignore = true)
    @Override
    SysDictData voToEntityIgnoreId(SysDictDataVo v);
}